package de.revdev.llt.bean.entities;

import de.revdev.llt.bean.entities.interfaces.EntityInterface;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author f.lindermaier
 */
@Entity
@Table(name = "tbl_history")
public class History implements Serializable, EntityInterface {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String answer;
    private String question;
    @Temporal(TemporalType.TIMESTAMP)
    private Date whenModified;
    @ManyToOne
    @JoinColumn(name = "id_fileCard")
    private FileCard fileCard;

    public History() {
    }

    public History(FileCard fileCard) {
        this.answer = fileCard.getAnswer();
        this.question = fileCard.getQuestion();
        this.whenModified = fileCard.getLastModified();
        this.fileCard = fileCard;
    }

    @Override
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getAnswer() {
        return answer;
    }

    public void setAnswer(String answer) {
        this.answer = answer;
    }

    public String getQuestion() {
        return question;
    }

    public void setQuestion(String question) {
        this.question = question;
    }

    public Date getWhenModified() {
        return whenModified;
    }

    public void setWhenModified(Date whenModified) {
        this.whenModified = whenModified;
    }

    public FileCard getFileCard() {
        return fileCard;
    }

    public void setFileCard(FileCard fileCard) {
        this.fileCard = fileCard;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof History)) {
            return false;
        }
        History other = (History) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "de.revdev.llt.bean.entities.History[ id=" + id + " ]";
    }
}
